package com.nervenets.template.service;

import com.fasterxml.jackson.core.JsonGenerator;
import com.nervenets.general.annotation.JsonGhostlyHandler;
import com.nervenets.template.hibernate.domain.user.Manager;
import lombok.SneakyThrows;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created by joe on 2024/3/14.
 */
@Component
public class ManagerJsonGhostlyHandler implements JsonGhostlyHandler<Long> {
    @Resource
    private ManagerService managerService;

    @SneakyThrows
    @Override
    public void ghostly(Long aLong, JsonGenerator generator) {
        generator.writeStringField("test", "8888888888");
        Manager byCache = managerService.findByCache(aLong);
        generator.writeObjectField("handlerUser", byCache);
    }
}
